<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="css/mui.min.css">
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">图片轮播</h1>
		</header>
		<div class="mui-content">		
			<div id="slider" class="mui-slider" >
				
			</div>
		</div>
		
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init({
				swipeBack:true //启用右滑关闭功能
			});
			
			// 示例数据
			var data = [
				{'img': 'http://dcloud.io/hellomui/images/shuijiao.jpg', 'href': 'http://www.dcloud.io'},
				{'img': 'http://dcloud.io/hellomui/images/muwu.jpg', 'href': 'http://www.dcloud.io'},
				{'img': 'http://dcloud.io/hellomui/images/cbd.jpg', 'href': 'http://www.dcloud.io'}
			]
			
			var len = data.length;
			
			// 图片
			var sliderGroup = document.createElement("div");
			sliderGroup.className = "mui-slider-group mui-slider-loop";
			var group  = '<div class="mui-slider-item mui-slider-item-duplicate">'+
				'<a href="'+data[len-1].href+'">'+
					'<img src="'+data[len-1].img+'">'+
				'</a>'+
			'</div>';
			for(var i=0; i < len;i++){
				group += '<div class="mui-slider-item">'+
					'<a href="'+data[i].href+'">'+
						'<img src="'+data[i].img+'">'+
					'</a>'+
				'</div>';
			}
			group += '<div class="mui-slider-item mui-slider-item-duplicate">'+
				'<a href="'+ data[0].href +'">'+
					'<img src="'+data[0].img+'">'+
				'</a>'+
			'</div>';
			sliderGroup.innerHTML = group;
			
			// 圆点
			var sliderIndicator = document.createElement("div");
			sliderIndicator.className = "mui-slider-indicator";
			for(var i=0; i < len;i++){
				var item = document.createElement("div");
				item.className = "mui-indicator";
				if(i==0){
					item.classList.add('mui-active');
				}
				sliderIndicator.appendChild(item);
			}
				
			var slider = document.getElementById('slider');
			slider.appendChild(sliderGroup);
			slider.appendChild(sliderIndicator);
			
			mui("#slider").slider({
				interval: 5000
			});
		</script>
	</body>

</html>